<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="Content-Type"; content="multipart/form-data; charset=utf-8"/>
		<title>云上书屋管理端</title>
		<link rel="stylesheet" href="http://47.100.102.177:8080/app/css/admin/admin.css">
		<link rel="icon" href="http://47.100.102.177:8080/app/plugin/管理.png" type="image/x-icon" />
		<link rel="stylesheet" href="http://47.100.102.177:8080/app/css/common/bootstrap.min.css">
		<link rel="stylesheet" href="../../boot/plugin/download/font_2801350_hw9pyy8c125/iconfont.css">
		<script src="http://47.100.102.177:8080/app/js/common/jquery.min.js"></script>
		<script type="text/javascript" src="http://47.100.102.177:8080/app/js/common/bootstrap.min.js"></script>
		<script src="http://47.100.102.177:8080/app/js/common/jquery-1.12.4.js"></script>
		<!-- 必须先引入vue，  后使用element-ui -->
		<script src="../../boot/plugin/element/vue.js"></script>
		<!--引入 element-ui 的样式，-->
		<link rel="stylesheet" href="../../boot/plugin/element/element.css">
		<!-- 引入element 的组件库-->
		<script src="../../boot/plugin/element/element.js"></script>
	</head>

	<body>
		<div class="head">
			<div class="head-left">
				<a href="#">
					<i class="iconfont">&#xe653;</i>
					<span>云上管理</span>
				</a>
			</div>
			<div class="head-middle">
				<ul id="one-menu" class="nav nav-pills">
					<!-- <li role="presentation" class="active"><a href="#">首页</a></li> -->
					<li id="menu1" role="presentation">
						<a href="#">
							<i class="iconfont">&#xe698;</i> &nbsp; 首页
						</a>
					</li>

					<li role="presentation" class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
							<i class="iconfont">&#xe61d;</i> &nbsp; 人员管理 <span class="caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li id="menu2-1"><a href="#">基本信息表(所有人员)</a></li>
							<li role="separator" class="divider"></li>
							<li id="menu2-2"><a href="#">管理员表</a></li>
							<li id="menu2-3"><a href="#">用户表</a></li>
						</ul>
					</li>

					<li role="presentation" class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
							<i class="iconfont">&#xe600;</i> &nbsp; 商品管理 <span class="caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li id="menu3-1"><a href="#">书籍信息表</a></li>
							<li id="menu3-2"><a href="#">热门书摘</a></li>
							<li id="menu3-3"><a href="#">电子书信息表</a></li>
							<li id="menu3-4"><a href="#">VIP价格信息表</a></li>
						</ul>
					</li>

					<li role="presentation" class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
							<i class="iconfont">&#xebef;</i> &nbsp; 类别管理 <span class="caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li id="menu4-1"><a href="#">书籍类别表</a></li>
						</ul>
					</li>

					<li role="presentation" class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
							<i class="iconfont">&#xe615;</i> &nbsp; 订单管理 <span class="caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li id="menu5-1"><a href="#">订单表</a></li>
							<li id="menu5-2"><a href="#">退款申请表</a></li>
						</ul>
					</li>

					<li id="menu6" role="presentation">
						<a href="#">
							<i class="iconfont">&#xe670;</i> &nbsp; 公告
						</a>
					</li>
				</ul>
			</div>
			<div class="head-right">
				<ul>
					<li class="sixin" style="margin-right: 30px;">
						<i class="iconfont" style="font-size: 30px;float: left;color: #3E8EF7;">&#xe628;</i>
						<sup class="sup"></sup>
						<div class="chat" style="position: fixed;top:50px;right: 0px;">
							<div id="app1">
								<template>
									<el-tabs v-model="activeName" @tab-click="handleClick">
										<el-tab-pane label="新消息" name="first">
											<ul id="chat-ul">

											</ul>
										</el-tab-pane>
										<el-tab-pane label="历史消息" name="second">
											<form>
												<div class="form-inline">
													<label for="send_peopleAccount">对方账号</label>
													<input type="text" class="form-control" id="send_peopleAccount" name="userPeopleId" style="width: 150px;" placeholder="请输入对方账号">
													<button type="button" class="btn btn-default" onclick="searchHistoryChat()">查询</button>
												</div>
											</form>

											<div style="width: 100%;height: 75vh;overflow-y: scroll;">
												<div id="history-ul" style="padding: 10px">

												</div>
											</div>


										</el-tab-pane>
									</el-tabs>
								</template>
							</div>
						</div>
					</li>
					<li class="admin-li">
						<div class="admin-img" id="admin_img">
							<div id="app">
								<el-upload
										class="avatar-uploader"
										action="https://jsonplaceholder.typicode.com/posts/"
										:show-file-list="false"
										:on-success="handleAvatarSuccess"
										:before-upload="beforeAvatarUpload">
									<img v-if="imageUrl" :src="imageUrl" class="avatar">
									<i v-else class="el-icon-plus avatar-uploader-icon"></i>
								</el-upload>
							</div>
						</div>

						<span style="float: left; margin-left: 10px;margin-right: 20px;">尊敬的&nbsp;<h4 id="admin_name" style="color: red; display: inline;"></h4>&nbsp;欢迎您!</span>
						<ul class="user" style="clear: both;position: fixed;top:50px;right: 0px;">
							<li><a href="#" id="all_inf" onclick="all_inf()">完善信息</a></li>
							<li><a href="#" id="update_password" onclick="update_password()">修改昵称或密码</a></li>
							<li><a href="/boot/admin/login">退出登录</a></li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		<div class="middle">
			<div style="position: relative;">
				<div class="middlek one">
					<!-- 首页 -->
					<iframe src="EChat"></iframe>
				</div>
				<div class="middlek two">
					<!-- 基本信息表(所有人员) -->
					<iframe src="getAllPeople?account=${param.account}"></iframe>
				</div>
				<div class="middlek three">
					<!-- 管理员表 -->
					<iframe src="getAllAdmin?account=${param.account}"></iframe>
				</div>
				<div class="middlek four">
					<!-- 用户表 -->
					<iframe src="findAllUser?account=${param.account}"></iframe>
				</div>
				<div class="middlek five">
					<!-- 书籍信息表 -->
					<iframe src="findAllBook?account=${param.account}"></iframe>
				</div>
				<div class="middlek six">
					<!-- 热门书摘表 -->
					<iframe src="findAllHot?account=${param.account}"></iframe>
				</div>
				<div class="middlek seven">
					<!-- 电子书信息表 -->
					<iframe src="findAllEBook?account=${param.account}"></iframe>
				</div>
				<div class="middlek eight">
					<!-- VIP价格信息表 -->
					<iframe src="getAllVip?account=${param.account}"></iframe>
				</div>
				<div class="middlek nine">
					<!-- 书籍类别表 -->
					<iframe src="getAllBookType?account=${param.account}"></iframe>
				</div>
				<div class="middlek oneone">
					<!-- 订单表 -->
					<iframe src="getAllList?account=${param.account}"></iframe>
				</div>
				<div class="middlek onefour">
					<!-- 退款申请表 -->
					<iframe src="getAllBack?account=${param.account}"></iframe>
				</div>
				<div class="middlek onetwo">
					<!-- 公告src="in-admin/公告.html?" -->
					<iframe id="send_phone"></iframe>
				</div>
			</div>
		</div>
		<div class="bg">
			<div class="inf">
				<div class="inf-head">
					<h4 style="color: white;display: inline;line-height: 30px;margin-left: 5px;">来信</h4>
					<input type="button" id="close" value="×">
				</div>
				<div class="inf-from" id="message">
					<form id="fromOfChat">
						<li>
						<span>来自@&nbsp;
							<h5 id="h51" style="color: red; display: inline;"></h5>(
							<h5 id="h52" style="color: red; display: inline;"></h5>)&nbsp;的来信:
						</span>
							<hr>
							<p id="text">&nbsp;&nbsp;&nbsp;&nbsp;</p>
							<hr>
							<span style="float:right;"></span>
						</li>
						<div style="width: 100%;height: 30px;"></div>
						<div>
							<button type="button" class="btn btn-info" style="float:left;margin-left:30px;" onclick="reply()">回复</button>
							<button type="button" class="btn btn-warning" style="float:right;margin-right:30px;" onclick="clean(this)">忽略</button>
							<div style="width:100%;height:60px;"></div>
							<div id="reply" style="display:none;margin:30px auto">
							<span>@&nbsp;
								<h5 style="color: red; display: inline;" id="replyName"></h5>(<h5 style="color: red; display: inline;">${param.account}</h5>)&nbsp;的回复:
							</span>
								<textarea style="margin-top:10px;" id="chatText" class="form-control" rows="8"></textarea>
								<button type="button" class="btn btn-success" style="float:left;margin-left:30px;margin-top:15px;" onclick="send(this)">发送</button>
								<span id="s" style="float:right;margin-right:30px;margin-top:20px;"></span>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="bg_1">
			<div class="inf">
				<div class="inf-head">
					<h4 style="color: white;display: inline;line-height: 30px;margin-left: 5px;">修改昵称和密码</h4>
					<input type="button" id="close_1" value="×">
				</div>
				<div class="inf-from" id="update">
					<form>
						<div class="form-group">
							<label for="exampleInputNickname">昵称</label>
							<label class="tip tip1">昵称格式错误,应该为1~7位字符</label>
							<input type="text" class="form-control" id="exampleInputNickname">
						</div>
						<button type="button" class="btn btn-default" id="changeNickName">修改昵称</button>
					</form>

					<br>
					<hr>
					<form id="update_form">
						<div class="form-group">
							<label for="exampleInputAccount">账号</label>
							<input type="text" class="form-control" id="exampleInputAccount" value="${param.account}" disabled>
						</div>
						<div class="form-group">
							<label for="exampleInputOldPassword">原密码</label>
							<label class="tip tip2 two_1">密码不能为空</label>
							<label class="tip tip2 two_2">密码错误</label>
							<input type="password" class="form-control" id="exampleInputOldPassword" placeholder="原密码">
						</div>
						<div class="form-group">
							<label for="exampleInputNewPassword">新密码</label>
							<label class="tip tip3 three">密码格式错误,必须是6~18位,字母开头,数字,下划线</label>
							<label class="tip tip3 three_1">密码不能为空</label>
							<input type="password" class="form-control" id="exampleInputNewPassword" placeholder="新密码">
						</div>
						<button type="button" class="btn btn-default" id="change">修改密码</button>
					</form>
				</div>
			</div>
		</div>

		<div class="bg_2">
			<div class="inf">
				<div class="inf-head">
					<h4 style="color: white;display: inline;line-height: 30px;margin-left: 5px;">完善信息</h4>
					<input type="button" id="close_2" value="×">
				</div>
				<div class="inf-from" id="complete">
					<form id="people_from">
						<div class="form-group">
							<label for="name">姓名</label>
							<input type="text" class="form-control" name="name" id="name">
						</div>
						<div class="form-group">
							<label for="people_num">身份证号</label>
							<input type="text" class="form-control" name="idNum" id="people_num">
						</div>
						<div class="form-group">
							<label>性别</label>
							<br>
							<select class="form-control" id="sex" name="sex">
								<option>男</option>
								<option>女</option>
							</select>
						</div>
						<div class="form-group">
							<label for="age">年龄</label>
							<input type="text" name="age" class="form-control" id="age">
						</div>
						<div class="form-group">
							<label for="birthday">生日</label>
							<input type="date" name="birthday" class="form-control" id="birthday">
						</div>
						<div class="form-group">
							<label for="tel">电话</label>
							<input type="text" name="phone" class="form-control" id="tel" value="${param.account}">
						</div>
						<div class="form-group">
							<label for="email">邮箱</label>
							<input type="text" name="email" class="form-control" id="email">
						</div>
						<div class="form-group">
							<label for="QQ">QQ</label>
							<input type="text" name="qq" class="form-control" id="QQ">
						</div>
						<div class="form-group">
							<label for="WX">微信</label>
							<input type="text" name="wx" class="form-control" id="WX">
						</div>
						<button type="button" onclick="save()" class="btn btn-default">保存</button>
						<button type="reset" class="btn btn-default">重置</button>
					</form>
				</div>
			</div>
		</div>

		<div id="changeChat" style="display: none"></div>

		<script>
			let account = ${param.account}
			var Main = {
				data() {
					return {
						imageUrl: '/boot/imgs/${people.headUrl}'
					};
				},
				methods: {
					handleAvatarSuccess(res, file) {
						this.imageUrl = URL.createObjectURL(file.raw);
						let fd = new FormData();
						fd.append("file", file.raw);
						fd.append("account",account);
						$.ajax({
							url: "/boot/admin/changeImg",
							data: fd,
							type: "Post",
							dataType: "json",
							cache: false,//上传文件无需缓存
							processData: false,//用于对data参数进行序列化处理 这里必须false
							contentType: false, //必须
							success: function (res) {
								alert("上传完成!");
							},
						})
					},
					beforeAvatarUpload(file) {
						const isJPG = file.type === 'image/jpeg'||'image/gif'||'image/png';
						const isLt2M = file.size / 1024 / 1024 < 3;
						if (!isJPG) {
							this.$message.error("上传头像图片只能是图片格式!");
						}
						if (!isLt2M) {
							this.$message.error("上传头像图片大小不能超过 3MB!");
						}
						return isJPG && isLt2M;
					}
				}
			}
			var Ctor = Vue.extend(Main)
			new Ctor().$mount('#app')


			var Main1 = {
				data() {
					return {
						activeName: 'second'
					};
				},
				methods: {
					handleClick(tab, event) {
						console.log(tab, event);
					}
				}
			}
			var Ctor1 = Vue.extend(Main1)
			new Ctor1().$mount('#app1')
			//传递url,跨域传输
			$(function() {
				let send_phone = document.getElementById("send_phone");
				send_phone.src = 'getAllAnnouncement?' + 'account=' + account;


				let param = "account="+account;
				$.get('/boot/admin/getAdminName',param,function (res) {
					let admin = res.data;
					let admin_name = document.getElementById("admin_name");
					// alert(admin.nickName);
					admin_name.innerHTML=admin.nickName;
				});

				$.get('/boot/admin/getImgUrl',param,function (res){
					let imgUrl = res;
					$("#admin_img").css("background-image","url("+imgUrl+")")
				});

				$.get('/boot/admin/getChat',param,function (res){
					let chat_datas = res;
					let chat_ul = document.getElementById("chat-ul");
					let str = "";
					let j = chat_datas.length;
					let sup = document.getElementsByTagName("sup")[0];
					if (j >= 99) {
						j = "99+";
					}
					sup.innerHTML = j;
					for (let i = 0; i < chat_datas.length; i++) {
						let paramOfChat = "sendPeopleId="+parseInt(chat_datas[i].sendPeopleId);
						$.get('/boot/admin/getSendPeopleId',paramOfChat,function (res){
							//此处用的admin聊天,User不匹配
							let user = res;
							str += '<li><div href="#" id="' + chat_datas[i].chatId + '" onclick="chat(this)">';
							str += '<span class="come-from">@&nbsp;<h5 class="name" style="color: red; display: inline;">' + user.nickName +
									'</h5>(<h5 class="name" style="color: red; display: inline;">'+user.account+
									'</h5>)&nbsp;的来信:</span>';
							str += '<p class="text"><a href="#">' + chat_datas[i].chat + '</a></p>';
							str += '<span class="time">' + chat_datas[i].sendTime + '</span>';
							str += '</div></li>';
							chat_ul.innerHTML = str;
						})
					}
				})
			})
			self.setTimeout("changeChat1()",10000);
			let changeChat = document.getElementById("changeChat");
			function changeChat1(){
				let param = "account="+account;
				$.get('/boot/admin/getChat',param,function (res){
					if (res.length!=changeChat.innerHTML) {
						getChat();
					}else {

					}
					changeChat.innerHTML = res.length;
				})
				self.setTimeout("changeChat1()",10000);
				return changeChat.innerHTML;
			}
			function getChat(){
				let param = "account="+account;
				$.get('/boot/admin/getChat',param,function (res){
					let chat_datas = res;
					let chat_ul = document.getElementById("chat-ul");
					let str = "";
					let j = chat_datas.length;
					let sup = document.getElementsByTagName("sup")[0];
					if (j >= 99) {
						j = "99+";
					}
					sup.innerHTML = j;
					for (let i = 0; i < chat_datas.length; i++) {
						let paramOfChat = "sendPeopleId="+parseInt(chat_datas[i].sendPeopleId);
						$.get('/boot/admin/getSendPeopleId',paramOfChat,function (res){
							//此处用的admin聊天,User不匹配
							let user = res;
							str += '<li><div href="#" id="' + chat_datas[i].chatId + '" onclick="chat(this)">';
							str += '<span class="come-from">@&nbsp;<h5 class="name" style="color: red; display: inline;">' + user.nickName +
									'</h5>(<h5 class="name" style="color: red; display: inline;">'+user.account+
									'</h5>)&nbsp;的来信:</span>';
							str += '<p class="text"><a href="#">' + chat_datas[i].chat + '</a></p>';
							str += '<span class="time">' + chat_datas[i].sendTime + '</span>';
							str += '</div></li>';
							chat_ul.innerHTML = str;
						})
					}
				})
			}

			function chat(obj) {
				let bg = document.getElementsByClassName("bg");
				bg[0].style.display = "block";
				$("#reply").css("display","none");
				let nickName = obj.getElementsByClassName("come-from")[0].getElementsByClassName("name")[0].innerText;
				let sendAccount = obj.getElementsByClassName("come-from")[0].getElementsByClassName("name")[1].innerText;
				let text = obj.getElementsByClassName("text")[0].innerText;
				let h51 = document.getElementById("h51");
				h51.innerHTML=nickName;
				let h52 = document.getElementById("h52");
				h52.innerHTML=sendAccount;
				let p = document.getElementById("text");
				p.innerHTML=text;
				let replyName = document.getElementById("replyName");
				let admin_name = document.getElementById("admin_name");
				replyName.innerText=admin_name.innerText;
				let id = obj.id;
				let fromOfChat = document.getElementById("fromOfChat");
				fromOfChat.class=id;
			}
			function send(obj) {
				var flag = confirm("你确定要发送吗?");
				if (flag) {
					let takePeopleAccount = document.getElementById("h52").innerText;
					let sendPeopleAccount = ${param.account};
					let chatId = parseInt(document.getElementById("fromOfChat").class);
					let chat = document.getElementById("chatText").value;
					let sendTime = document.getElementById("s").innerText;
					let param1 = {chatId:chatId,takePeopleAccount:takePeopleAccount,sendPeopleAccount:sendPeopleAccount,chat:chat,sendTime:sendTime};
					$.get('/boot/admin/sendReply',param1,function (res){
						if (res.code=="200"){
							alert(res.msg);
							location.reload();
						}else {
							alert("发送失败")
						}
					});
				}
			}
			function clean(obj) {
				var flag = confirm("你确定要忽略该条信息吗吗?");
				if (flag) {
					let chatId = parseInt(document.getElementById("fromOfChat").class);
					let param = "chatId="+chatId;
					$.get('/boot/admin/notReply',param,function (res) {
						if (res.code=="200"){
							alert(res.msg);
							location.reload();
						}else {
							alert("忽略失败")
						}
					});
				}
			}
			function reply() {
				$("#reply").css("display", "block");
			}

			function searchHistoryChat(){
				let userAccount = document.getElementById("send_peopleAccount").value;
				let adminAccount = account;
				let param = {adminAccount:adminAccount,userAccount:userAccount};
				$.get('/boot/admin/historyChat',param,function (res){
					let history_str = "";
					let history_div = document.getElementById("history-ul");
					if (res!=null&&res.length>0){
						let history = res;
						for (let i=0;i<history.length;i++){
							let paramOfChat = "sendPeopleId="+parseInt(history[i].sendPeopleId);
							$.get('/boot/admin/getSendPeopleId',paramOfChat,function (res){
								let senderAccount = res.account;
								history_str += '<div style="width: 100%;margin-bottom: 10px;">';
								if (senderAccount==account){
									history_str += '<span style="float: right;">@<h5 style="color: red;display: inline">'+res.nickName+'('+res.account+')'+'</h5></span>';
									history_str += '<hr>';
									history_str += '<div style="width: 100%;float: right;line-height: 14px;font-size: 14px;text-align: right">'+history[i].chat+'<div>';
									history_str += '<div style="width: 100%;float: right;line-height: 14px;font-size: 14px;text-align: right">'+history[i].sendTime+'</div>';
									history_str += '<hr>';
								}else {
									history_str += '<span style="float: left;">@<h5 style="color: red;display: inline">'+res.nickName+'('+res.account+')'+'</h5></span>';
									history_str += '<hr>';
									history_str += '<div style="width: 100%;float: left;line-height: 14px;font-size: 14px;text-align: left">'+history[i].chat+'<div>';
									history_str += '<div style="width: 100%;float: left;line-height: 14px;font-size: 14px;text-align: left">'+history[i].sendTime+'</div>';
									history_str += '<hr>';
								}
								history_str += '</div>'
								history_str += '<br>';
								history_div.innerHTML = history_str;
							});
						};
					}else {
						history_str +='<h3 style="text-align: center;color: red">查询为空</h3>'
						history_div.innerHTML = history_str;
					}


				})
			}

			function all_inf(){
				let param = "account="+account;
				$.post('/boot/admin/findInf',param,function (res){
					let people = res;
					$("#name").val(people.name);
					$("#people_num").val(people.idNum);
					$("#sex").val(people.sex);
					$("#age").val(people.age);
					$("#birthday").val(people.birthday);
					$("#email").val(people.email);
					$("#QQ").val(people.qq);
					$("#WX").val(people.wx);
				});
			}
			function save(){
				let form = $("#people_from");
				let param = form.serialize();
				$.post('/boot/admin/savePeople',param,function (res){
					if (res.code=="200"){
						alert(res.msg);
						location.reload();
					}else {
						alert("不能有空");
					}
				});
			}

			$(function() {
				$("#menu1").click(function() {
					$(".middlek").css("display", "none");
					$(".one").css("display", "block");
				});
				$("#menu2-1").click(function() {
					$(".middlek").css("display", "none");
					$(".two").css("display", "block");
				});
				$("#menu2-2").click(function() {
					$(".middlek").css("display", "none");
					$(".three").css("display", "block");
				});
				$("#menu2-3").click(function() {
					$(".middlek").css("display", "none");
					$(".four").css("display", "block");
				});
				$("#menu3-1").click(function() {
					$(".middlek").css("display", "none");
					$(".five").css("display", "block");
				});
				$("#menu3-2").click(function() {
					$(".middlek").css("display", "none");
					$(".six").css("display", "block");
				});
				$("#menu3-3").click(function() {
					$(".middlek").css("display", "none");
					$(".seven").css("display", "block");
				});
				$("#menu3-4").click(function() {
					$(".middlek").css("display", "none");
					$(".eight").css("display", "block");
				});
				$("#menu4-1").click(function() {
					$(".middlek").css("display", "none");
					$(".nine").css("display", "block");
				});
				$("#menu4-2").click(function() {
					$(".middlek").css("display", "none");
					$(".ten").css("display", "block");
				});
				$("#menu5-1").click(function() {
					$(".middlek").css("display", "none");
					$(".oneone").css("display", "block");
				});
				$("#menu5-2").click(function() {
					$(".middlek").css("display", "none");
					$(".onefour").css("display", "block");
				});
				$("#menu6").click(function() {
					$(".middlek").css("display", "none");
					$(".onetwo").css("display", "block");
				});
				$("#menu7").click(function() {
					$(".middlek").css("display", "none");
					$(".onethree").css("display", "block");
				});


				$("#update_password").click(function() {
					$(".bg_1").css("display", "block");
				});
				$("#all_inf").click(function() {
					$(".bg_2").css("display", "block");
				})

				$("#close").click(function() {
					$(".bg").css("display", "none");
				});
				$("#close_1").click(function() {
					$(".bg_1").css("display", "none");
				});
				$("#close_2").click(function() {
					$(".bg_2").css("display", "none");
				});
			})

			function update_password() {
				let admin_name = document.getElementById("admin_name").innerText;
				let input_nickname = document.getElementById("exampleInputNickname");
				input_nickname.placeholder = admin_name;
			}

			//获取当前时间以字符串形式显示在span标签内
			//  2020/10/15 15:08:10
			function loadTime() {
				var currentDate = new Date();
				var dateStr = formatDate(currentDate);
				var span = document.getElementById("s");
				span.innerText = dateStr;
			}
			//日期对象 转换为 指定日期格式的字符串 yyyy/MM/dd HH:mm:ss
			function formatDate(date) {
				var str = date.getFullYear() + "/" + subDate((date.getMonth() + 1)) + "/" +
					subDate(date.getDate()) + " " + subDate(date.getHours()) + ":" +
					subDate(date.getMinutes()) + ":" + subDate(date.getSeconds());
				return str;
			}
			//补全日期 不足两位前面补0  5--05 10--10
			//先统一前面加0  05  010
			function subDate(s) {
				var s1 = "0" + s;
				return s1.substring(s1.length - 2);
			}

			onload = function() {
				//每隔1秒 执行loadTime方法
				setInterval(loadTime, 1000);
			};
			$(function() {
				$("#changeNickName").on('click',function (){
					var flag = true;
					let nickName_reg = /^.{1,7}$/;
					let newNickName = $("#exampleInputNickname").val();
					if (nickName_reg.test(newNickName)){
						$(".tip1").css("display", "none");
					}else {
						$(".tip1").css("display", "block");
						flag = false;
					}
					if (flag){
						let param = {account:account,newNickName:newNickName}
						$.get('/boot/admin/changeNickName',param,function (res){
							if (res.code=="200"){
								alert(res.msg);
								location.reload();
							}
						});
					}

				});
				$("#change").on('click', function() {
					if (confirm("你确定要修改密码吗?")) {
						var flag = true;
						let param = "account="+account;
						$.post('/boot/admin/changePassword',param,function (res){
							var password = res; //模拟原密码,真实数据根据账号查询出来
							var password_reg = /^[a-zA-Z]\w{5,17}$/;

							//原密码
							var oldpassword = $("#exampleInputOldPassword").val();
							if (oldpassword == '') {
								$(".tip2").css("display", "none");
								$(".two_1").css("display", "block");
								flag = false;
							} else if (oldpassword != password) {
								$(".tip2").css("display", "none");
								$(".two_2").css("display", "block");
								flag = false;
							} else {
								$(".tip2").css("display", "none");
							}

							//新密码
							var newpassword = $("#exampleInputNewPassword").val();
							if (newpassword == '') {
								$(".tip3").css("display", "none");
								$(".three_1").css("display", "block");
								flag = false;
							} else if (password_reg.test(newpassword)) {
								$(".tip3").css("display", "none");
							} else {
								$(".tip3").css("display", "none");
								$(".three").css("display", "block");
								flag = false;
							}

							if (flag) {
								let param1 = {account:account,newpassword:newpassword};
								$.post('/boot/admin/newPassword',param1,function (res1){
									if (res1.code=="200"){
										alert(res1.msg);
										window.location.href = '/boot/admin/login';
									}
								})
							}
						});
					}
				})
			})
		</script>
	</body>

</html>
